//
//  CalendarHeaderCell.m
//  RSW.IOS
//
//  Created by zhaiqiuqiu on 2017/12/9.
//  Copyright © 2017年 com.xtion.crm. All rights reserved.
//

#import "CalendarHeaderCell.h"

@interface CalendarHeaderCell()
{
    HeadImageView *_calendarImage;
    
    UILabel *_firstLabel;
    UILabel *_secondLabel;
    UILabel *_thirdLabel;
}
@end

@implementation CalendarHeaderCell

-(id)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    CGSize s = [NSString charSizeWithSystemFontSize:13];
    _firstLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, s.width*6, s.height)];
    _firstLabel.backgroundColor = [UIColor clearColor];
    _firstLabel.font = [UIFont systemFontOfSize:18];
    _firstLabel.textColor = [UIColor blackColor];
    [self.contentView addSubview:_firstLabel];
    
    _secondLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, s.width*6, s.height)];
    _secondLabel.backgroundColor = [UIColor clearColor];
    _secondLabel.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:_secondLabel];
    
    _thirdLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, s.width*6, s.height)];
    _thirdLabel.backgroundColor = [UIColor clearColor];
    _thirdLabel.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:_thirdLabel];
    
    _calendarImage = [[HeadImageView alloc]initWithFrame:CGRectMake(0,0, 20, 20)];
    _calendarImage.headImage = [UIImage imageNamed:@"img_defaulthead.png"];
    //[self.contentView addSubview:_calendarImage];
    //TODO
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    _firstLabel.left = 10;
    _firstLabel.centerY = self.contentView.height/2.0;
    
    _secondLabel.left = _firstLabel.right + 5;
    _secondLabel.centerY = self.contentView.height/4.0;
    
    _thirdLabel.left = _firstLabel.right + 5;
    _thirdLabel.centerY = self.contentView.height*3/4.0;
    
    _calendarImage.right = self.contentView.width - 10;
    _calendarImage.centerY = self.contentView.height/2.0;
}

-(void)setDate:(NSDate *)date
{
    _firstLabel.text = [date toStringDate:@"MM月dd日"];
    _secondLabel.text = [NSString stringWithFormat:@"%@",@([date year])];
    _thirdLabel.text = [[[CalendarTool alloc] init] getChineseDayWithDate:date];
}

+(CGFloat)caleHeight
{
    return 44;
}
@end
